// 04jyhs/shoppingMallAdmin/MallOrderAdmin/SendOutGoods/SendOutGoods.js
var co = require("../../../../resource/js/common.js")
var _this,_data
Page({
  /**
   * 页面的初始数据
   */
  data: {
     ordersList:[],
     pick_i: -1,
     isPicker: false,
     idx:null,
     sendArr:[],//配送方式
     inputText:null,
  },
  onLoad: function (opt) {
     _this=this
     _data=_this.data
     var orders = JSON.parse(opt.orders)
     _this.setData({
        ordersList: orders
     })
     _this.getsendMode()
  },
  //获取配送方式
  getsendMode() {
     co.getMealApi("jyhs/Shippingmg/getExpressCompany",{},function(res){
          if(res.code == 0){
              _this.setData({
                 sendArr:res.data
              })
          }
      })
  },
   // 分类选择器
   pickerClick: function (e) {
      var index = parseInt(e.detail.value)
      this.setData({ pick_i: e.detail.value, isPicker: false, idx: index })
   },
  onHide(){
     _this.setData({
        ordersList: []
     })
  },
   InputWaybillNumber(e) {
      _this.setData({
         inputText: e.detail.value
      })
   },
   //确定按钮事件
   YesSendGoods() {
      var param = {
         Order_ID: _data.ordersList.Order_ID
      }
      var Express_Name = _data.sendArr[_data.idx]
      if (co.empty(Express_Name)){//空值时不执行
         return
      }
      if (Express_Name == "商家配送"){
         param.Send_Type = "bizsend"
      }else{
         param.Send_Type = "express"
         param.Express_Name = Express_Name
         param.Shipping_ID = _data.inputText
      }
      co.getMealApi("jyhs/Ordmg/sendGoods",param,function(res){
          if(res.code == 0){
             co.toastAllText(res.msg)
             wx.navigateTo({
                url: '/04jyhs/shoppingMallAdmin/shoppingMallAdmin',
             })
          }
      })
   },
})